Drop fallback-c89.c
authorChristoph Reiter <reiter.christoph@gmail.com>
Sun, 31 May 2020 14:06:07 +0000 (16:06 +0200)
committerChristoph Reiter <reiter.christoph@gmail.com>
Sun, 31 May 2020 15:09:23 +0000 (17:09 +0200)
We require a C compiler supporting C99 now. The main purpose of
these fallbacks was for MSVC. From what I can see this is now all supported
by MSVC 2015+ anyway.

The only other change this includes is to replace isnanf() with the
(type infering) C99 isnan() macro, because MSVC doesn't provide isnanf().

28 files changed:
config.h.meson
gdk/fallback-c89.c [deleted file]
gdk/gdkdevice.c
gdk/gdkdisplay.c
gdk/gdkrgba.c
gdk/gdksurface.c
gdk/win32/gdksurface-win32.c
gtk/fallback-c89.c [deleted file]
gtk/gtkcssshorthandpropertyimpl.c
gtk/gtkcssstyleproperty.c
gtk/gtkcssstylepropertyimpl.c
gtk/gtkentry.c
gtk/gtkicontheme.c
gtk/gtkkineticscrolling.c
gtk/gtklabel.c
gtk/gtklevelbar.c
gtk/gtknumericsorter.c
gtk/gtkprogressbar.c
gtk/gtkrender.c
gtk/gtkrenderbackground.c
gtk/gtkrenderborder.c
gtk/gtkrevealer.c
gtk/gtkswitch.c
gtk/gtktext.c
gtk/gtkwidget.c
gtk/inspector/visual.c
gtk/meson.build
meson.build

index fac759a2a7b19552e3b62813beb1868b5bdab87d..ee5ddbf7b3a1d4b5aaa951a6411da0724dae3a78 100644 (file)
 /* Define to 1 if you have the `dcgettext' function. */
 #mesondefine HAVE_DCGETTEXT
 
-/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't.
-   */
-#mesondefine HAVE_DECL_ISINF
-
-/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.
-   */
-#mesondefine HAVE_DECL_ISNAN
-
-/* Define to 1 if you have the declaration of `isnanf', and to 0 if you don't.
-   */
-#mesondefine HAVE_DECL_ISNANF
-
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #mesondefine HAVE_DLFCN_H
 
@@ -84,9 +72,6 @@
 /* Define to 1 if you have a working `mmap' system call. */
 #mesondefine HAVE_MMAP
 
-/* Define to 1 if you have the `nearbyint' function. */
-#mesondefine HAVE_NEARBYINT
-
 /* Define to 1 if you have the `posix_fallocate' function. */
 #mesondefine HAVE_POSIX_FALLOCATE
 
 /* Have the Xrandr 1.5 extension library */
 #mesondefine HAVE_RANDR15
 
-/* Define to 1 if you have the `rint' function. */
-#mesondefine HAVE_RINT
-
-/* Define to 1 if you have the `round' function. */
-#mesondefine HAVE_ROUND
-
 /* Define to 1 if you have the `sincos' function. */
 #mesondefine HAVE_SINCOS
 
-/* Define to 1 if you have the `log2` function */
-#mesondefine HAVE_LOG2
-
-/* Define to 1 if you ahve the `exp2` function */
-#mesondefine HAVE_EXP2
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #mesondefine HAVE_STDINT_H
 
diff --git a/gdk/fallback-c89.c b/gdk/fallback-c89.c
deleted file mode 100644 (file)
index e9adc5e..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2011 Chun-wei Fan <fanc999@yahoo.com.tw>
- *
- * Author: Chun-wei Fan <fanc999@yahoo.com.tw>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include <float.h>
-
-#ifndef HAVE_DECL_ISNAN
-/* it seems of the supported compilers only
- * MSVC does not have isnan(), but it does
- * have _isnan() which does the same as isnan()
- */
-static inline gboolean
-isnan (double x)
-{
-  return _isnan (x);
-}
-#endif
-
-#ifndef HAVE_DECL_ISINF
-/* Unfortunately MSVC does not have finite()
- * but it does have _finite() which is the same
- * as finite() except when x is a NaN
- */
-static inline gboolean
-isinf (double x)
-{
-  return (!_finite (x) && !_isnan (x));
-}
-#endif
-
-/* Workaround for round() for non-GCC/non-C99 compilers */
-#ifndef HAVE_ROUND
-static inline double
-round (double x)
-{
-  if (x >= 0)
-    return floor (x + 0.5);
-  else
-    return ceil (x - 0.5);
-}
-#endif
index 11823ec919315297f400c229cec9bc460d7a8bf2..98cbd8806bfc61d79cb10e314d440a8962ea8f6b 100644 (file)
@@ -26,9 +26,6 @@
 #include "gdkintl.h"
 #include "gdkkeysprivate.h"
 
-/* for the use of round() */
-#include "fallback-c89.c"
-
 /**
  * SECTION:gdkdevice
  * @Short_description: Object representing an input device
index 81277b9f7bf6d2b22bfaab745defa4bb4fe722fc..9e6853391d5ef6d89d9fdac580ab21ebff7c5184 100644 (file)
@@ -38,9 +38,6 @@
 #include <math.h>
 #include <glib.h>
 
-/* for the use of round() */
-#include "fallback-c89.c"
-
 /**
  * SECTION:gdkdisplay
  * @Short_description: Controls a set of monitors and their associated input devices
index 0242e8f945a29f7f169bd4226bc7b550be90ef22..b8bd025d3bb5c7d089edc5cc786959a85e0124cc 100644 (file)
@@ -30,8 +30,6 @@
 #include <errno.h>
 #include <math.h>
 
-#include "fallback-c89.c"
-
 /**
  * SECTION:rgba_colors
  * @Short_description: RGBA colors
index f0ef1eeb8e4fef4bc295de9c428c04a67947f805..1c5aeb180ac739797738199ebd04e52762d00352 100644 (file)
@@ -47,9 +47,6 @@
 
 #include <epoxy/gl.h>
 
-/* for the use of round() */
-#include "fallback-c89.c"
-
 #ifdef GDK_WINDOWING_WAYLAND
 #include "wayland/gdkwayland.h"
 #endif
index d26b64ebd2b82a69cb50410781ea0e685c0135c0..5edb59e9a837538b62072cce4c20b86b7b065914 100644 (file)
@@ -49,7 +49,6 @@
 #include <cairo-win32.h>
 #include <dwmapi.h>
 #include <math.h>
-#include "fallback-c89.c"
 
 static void gdk_surface_win32_finalize (GObject *object);
 
diff --git a/gtk/fallback-c89.c b/gtk/fallback-c89.c
deleted file mode 100644 (file)
index 65cb535..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2011 Chun-wei Fan <fanc999@yahoo.com.tw>
- *
- * Author: Chun-wei Fan <fanc999@yahoo.com.tw>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include <math.h>
-#include <float.h>
-
-/* Workaround for round() for non-GCC/non-C99 compilers */
-#ifndef HAVE_ROUND
-static inline double
-round (double x)
-{
-  if (x >= 0)
-    return floor (x + 0.5);
-  else
-    return ceil (x - 0.5);
-}
-#endif
-
-/* Workaround for rint() for non-GCC/non-C99 compilers */
-#ifndef HAVE_RINT
-static inline double
-rint (double x)
-{
-  if (ceil (x + 0.5) == floor (x + 0.5))
-  {
-    int a;
-    a = (int) ceil (x);
-    if (a % 2 == 0)
-      return ceil (x);
-    else
-      return floor (x);
-  }
-  else
-  {
-    if (x >= 0)
-      return floor (x + 0.5);
-    else
-      return ceil (x - 0.5);
-  }
-}
-#endif
-
-#ifndef HAVE_NEARBYINT
-/* Workaround for nearbyint() for non-GCC/non-C99 compilers */
-/* This is quite similar to rint() in most respects */
-
-static inline double
-nearbyint (double x)
-{
-  return floor (x + 0.5);
-}
-#endif
-
-#ifndef HAVE_DECL_ISINF
-/* Unfortunately MSVC does not have finite()
- * but it does have _finite() which is the same
- * as finite() except when x is a NaN
- */
-static inline gboolean
-isinf (double x)
-{
-  return (!_finite (x) && !_isnan (x));
-}
-#endif
-
-#ifndef HAVE_DECL_ISNAN
-/* it seems of the supported compilers only
- * MSVC does not have isnan(), but it does
- * have _isnan() which does the same as isnan()
- */
-static inline gboolean
-isnan (double x)
-{
-  return _isnan (x);
-}
-#endif
-
-#ifndef HAVE_DECL_ISNANF
-#if defined (__GNUC__)
-/* gcc has an intern function that it warns about when
- * using -Wshadow but no header properly declares it,
- * so we do it instead.
- */
-extern int isnanf (float x);
-#else
-static inline int
-isnanf (float x)
-{
-  /* Either use the C99 type infering macro, or the fallback from above.
-   * MSVC has _isnanf, but only on x64
-   */
-  return isnan (x);
-}
-#endif
-#endif
-
-#ifndef INFINITY
-/* define INFINITY for compilers that lack support for it */
-# ifdef HUGE_VALF
-#  define INFINITY HUGE_VALF
-# else
-#  define INFINITY (float)HUGE_VAL
-# endif
-#endif
-
-#ifndef HAVE_LOG2
-/* Use a simple implementation for log2() for compilers that lack it */
-static inline double
-log2 (double x)
-{
-  return log (x) / log (2.0);
-}
-#endif
-
-#ifndef HAVE_EXP2
-/* Use a simple implementation for exp2() for compilers that lack it */
-static inline double
-exp2 (double x)
-{
-  return pow (2.0, x);
-}
-#endif
index 82b5893151c147b2cdb669ab162fdc0af6b9f174..4a9b97fd07ba215a21a83cfc8c4acb93b4872682 100644 (file)
 #include "gtkcssvalueprivate.h"
 #include "gtktypebuiltins.h"
 
-/* this is in case round() is not provided by the compiler, 
- * such as in the case of C89 compilers, like MSVC
- */
-#include "fallback-c89.c"
-
 /*** PARSING ***/
 
 static gboolean
index 0fe1bab13456203f9bfb00de80f7de8dfcde3256..eebf39ad48fb228caec9a6614425eab1d875e42e 100644 (file)
 #include "gtkprivatetypebuiltins.h"
 #include "gtkprivate.h"
 
-/* this is in case round() is not provided by the compiler, 
- * such as in the case of C89 compilers, like MSVC
- */
-#include "fallback-c89.c"
-
 enum {
   PROP_0,
   PROP_ANIMATED,
index 94cd77f6a14c05a4838e24d9279b5a433f162759..eabafee6df3eda893319d92baca1b4f2b90ce9a4 100644 (file)
 #include "gtkintl.h"
 #include "gtkprivatetypebuiltins.h"
 
-/* this is in case round() is not provided by the compiler, 
- * such as in the case of C89 compilers, like MSVC
- */
-#include "fallback-c89.c"
-
 /* the actual parsers we have */
 #include "gtkcssarrayvalueprivate.h"
 #include "gtkcssbgsizevalueprivate.h"
index 7a308498466681668126ee60cf3178493f1c1c28..3bb4178da68d843f6cd6fa9135e1103d28b27adb 100644 (file)
@@ -75,8 +75,6 @@
 #include <cairo-gobject.h>
 #include <string.h>
 
-#include "fallback-c89.c"
-
 /**
  * SECTION:gtkentry
  * @Short_description: A single line text entry field
index c29d2b7a8a6d70cee6ad0490130db7f3f7c78540..1b40a1e438496b6a015eddb1510eab8b684d4931 100644 (file)
 #include "gdk/gdktextureprivate.h"
 #include "gdk/gdkprofilerprivate.h"
 
-/* this is in case round() is not provided by the compiler,
- * such as in the case of C89 compilers, like MSVC
- */
-#include "fallback-c89.c"
-
 /**
  * SECTION:gtkicontheme
  * @Short_description: Looking up icons by name
index 7acd0966801dc23bb4791a6a2d6c124c4021af62..212319b9336e737f7dffaa14f87ad91618f9fd21 100644 (file)
 #include "config.h"
 #include "gtkkineticscrollingprivate.h"
 
+#include <math.h>
 #include <stdio.h>
 
-#include "fallback-c89.c"
-
 /*
  * All our curves are second degree linear differential equations, and
  * so they can always be written as linear combinations of 2 base
index 688c4b3460fbfb83c4d5b574e1fea8b17a9de4f6..3a8e675c85d9b8a74b63ea6605d46cdfab7a989d 100644 (file)
 #include <math.h>
 #include <string.h>
 
-/* this is in case rint() is not provided by the compiler, 
- * such as in the case of C89 compilers, like MSVC
- */
-#include "fallback-c89.c"
-
 /**
  * SECTION:gtklabel
  * @Short_description: A widget that displays a small to medium amount of text
index d00a03f1f34265bf8b5ff45a4cafa26b126af40f..caafb489f4c25d4938176fee136dbcbd327cc4a8 100644 (file)
 
 #include "a11y/gtklevelbaraccessible.h"
 
-#include "fallback-c89.c"
-
 enum {
   PROP_VALUE = 1,
   PROP_MIN_VALUE,
index 253fd201d74622f15a0d7f0aea23d9b88045d2e3..eac561241bbef97dae7d4ec543763b999b1ebbaa 100644 (file)
@@ -25,7 +25,6 @@
 #include "gtktypebuiltins.h"
 
 #include <math.h>
-#include "fallback-c89.c"
 
 /**
  * SECTION:gtknumericsorter
@@ -127,11 +126,11 @@ gtk_numeric_sorter_compare (GtkSorter *sorter,
         float num1 = g_value_get_float (&value1);
         float num2 = g_value_get_float (&value2);
 
-        if (isnanf (num1) && isnanf (num2))
+        if (isnan (num1) && isnan (num2))
           result = GTK_ORDERING_EQUAL;
-        else if (isnanf (num1))
+        else if (isnan (num1))
           result = self->sort_order == GTK_SORT_ASCENDING ? GTK_ORDERING_LARGER : GTK_ORDERING_SMALLER;
-        else if (isnanf (num2))
+        else if (isnan (num2))
           result = self->sort_order == GTK_SORT_ASCENDING ? GTK_ORDERING_SMALLER : GTK_ORDERING_LARGER;
         else if (num1 < num2)
           result = self->sort_order == GTK_SORT_ASCENDING ? GTK_ORDERING_SMALLER : GTK_ORDERING_LARGER;
index 83f2aeaf89a342f65be8a5e23463323fdecff268..58164c4e7e28b23aac260d9b76b25138ba2d09f4 100644 (file)
@@ -43,8 +43,6 @@
 
 #include <string.h>
 
-#include "fallback-c89.c"
-
 /**
  * SECTION:gtkprogressbar
  * @Short_description: A widget which indicates progress visually
index c11e377aafa653c2ab0ad2447021f95b22102c7b..6ddfa4998a5cdaa7d85803f9350571612a425c0b 100644 (file)
@@ -34,8 +34,6 @@
 #include "gsk/gskroundedrectprivate.h"
 #include <gdk/gdktextureprivate.h>
 
-#include "fallback-c89.c"
-
 static void
 gtk_do_render_icon (GtkStyleContext        *context,
                     cairo_t                *cr,
index e3661888529d7d8ce55dab8b29148dee98538486..fb17730900dbc24eae5b4de2d74daa3d2eb9257d 100644 (file)
 
 #include "gsk/gskroundedrectprivate.h"
 
-/* this is in case round() is not provided by the compiler, 
- * such as in the case of C89 compilers, like MSVC
- */
-#include "fallback-c89.c"
-
 static void
 gtk_theming_background_snapshot_color (GtkCssBoxes       *boxes,
                                        GtkSnapshot       *snapshot,
index e56d48e16ce155a3c95d0ed309cde4f9c2557ba4..1846ace0f945794d08c9735787806aeb1f2a706f 100644 (file)
 
 #include "gsk/gskroundedrectprivate.h"
 
-/* this is in case round() is not provided by the compiler, 
- * such as in the case of C89 compilers, like MSVC
- */
-#include "fallback-c89.c"
-
 typedef struct _GtkBorderImage GtkBorderImage;
 
 struct _GtkBorderImage {
index 74fdf52f90894083940ccf3b557c78063a298edf..158152480cec198b43b5f479c9cc918a18184945 100644 (file)
@@ -32,8 +32,6 @@
 #include "gtkwidgetprivate.h"
 #include "gtkbuildable.h"
 
-#include "fallback-c89.c"
-
 /**
  * SECTION:gtkrevealer
  * @Short_description: Hide and show with animation
index 79f0b5c65275036e7f600e11c24568e6330aca2c..99ac45f94142132fc7be316c66eaf5c239e87999 100644 (file)
@@ -71,8 +71,6 @@
 
 #include "a11y/gtkswitchaccessible.h"
 
-#include "fallback-c89.c"
-
 typedef struct _GtkSwitchClass   GtkSwitchClass;
 
 /**
index 5e6ee4be75793222b59e2ed88adf6ea7d590d438..77c469636fd2da30d705d1042d5c4d1aeb00243f 100644 (file)
@@ -73,8 +73,6 @@
 #include <cairo-gobject.h>
 #include <string.h>
 
-#include "fallback-c89.c"
-
 /**
  * SECTION:gtktext
  * @Short_description: A simple single-line text entry field
index 96f4656d4cd0085fa0b0d58eb3fda2bf8ac2a3fb..18a6b048fae528fb5d4c78c69bea82ec1c23022c 100644 (file)
@@ -90,9 +90,6 @@
 #include <stdarg.h>
 #include <string.h>
 
-/* for the use of round() */
-#include "fallback-c89.c"
-
 /**
  * SECTION:gtkwidget
  * @Short_description: Base class for all widgets
index 4840f7292632594996e3873fad9993933544b700..7f1b40d63512f98a9849c17252dbc2f3cb1c6b01 100644 (file)
@@ -45,8 +45,6 @@
 #include "gtkeditable.h"
 #include "gtkentry.h"
 
-#include "fallback-c89.c"
-
 #ifdef GDK_WINDOWING_X11
 #include "x11/gdkx.h"
 #endif
index 448de76888ae34e6f8b8beb9876e25ecc7987a3a..c8ebb97168441d38a600b2a3725e0de6a35811b3 100644 (file)
@@ -14,7 +14,6 @@ gtk_cargs = [
 # List of sources that do not contain public API, and should not be
 # introspected
 gtk_private_sources = files([
-  'fallback-c89.c',
   'fnmatch.c',
   'tools/gdkpixbufutils.c',
   'gsettings-mapping.c',
index 874fee25a869cf271523b1f1a802ed95fccbbd4d..92951636034052559d2d04153a870ce9790ba996 100644 (file)
@@ -191,16 +191,11 @@ check_functions = [
   'getresuid',
   'lstat',
   'mmap',
-  'nearbyint',
   'posix_fallocate',
   '_lock_file',
   'flockfile',
   'mkstemp',
   'mallinfo',
-  'round',
-  'rint',
-  'log2',
-  'exp2',
   'sincos',
   'sincosf',
 ]
@@ -211,10 +206,6 @@ foreach func : check_functions
   endif
 endforeach
 
-cdata.set('HAVE_DECL_ISINF', cc.has_header_symbol('math.h', 'isinf'))
-cdata.set('HAVE_DECL_ISNAN', cc.has_header_symbol('math.h', 'isnan'))
-cdata.set('HAVE_DECL_ISNANF', cc.has_header_symbol('math.h', 'isnanf'))
-
 # Disable deprecation checks for all libraries we depend on on stable branches.
 # This is so newer versions of those libraries don't cause more warnings with
 # a stable GTK version.